<template>
    <div>
        <table>
            <tr>
                <td>名称</td>
                <td>操作</td>
            </tr>
            <tr v-for="i in list">
                <td>{{i.name}}</td>
                <td>
                    <button @click="del(i.id)">删除</button>
                    <button @click="updata1(i.id)">修改</button>
                </td>
            </tr>
        </table>
        <!-- {{list}} -->
    </div>
</template>

<script>
    export default {
        data(){
            return{
                list:[]
            }
        },
        methods:{
            getlist(){
                this.$axios.get('cateM')
                .then(res=>{
                    this.list=res.data.list
                })
            },
            del(id){
                this.$axios.delete('cateM?id='+id)
                .then(res=>{
                     this.$toast.fail('删除成功')
                        this.getlist()



                })
            },
            updata1(id){
              this.$router.push({path:'/update',query:{id:id}})
            },
        },
        mounted(){
            this.getlist()
        },
    }
</script>

<style scoped>

</style>